<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>活体申诉页面</title>
    <jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <!-- 查询表单 -->
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">客户名称</div>
                    <div class="field">
                        <input type="text" id="usrNm" name="usrNm" class="ui-textbox" ligerui="width: 160" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">身份证号</div>
                    <div class="field">
                        <input type="text" id="certNo" name="certNo" class="ui-textbox" ligerui="width: 160" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">活体类型</div>
                    <div class="field">
                        <select name="liveType" id="liveType">
                            <option value=" " selected="selected">请选择</option>
                            <option value="1">狮桥分</option>
                        </select>
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">审核状态</div>
                    <div class="field">
                        <select name="status" id="status">
                            <option value=" " selected="selected">请选择</option>
                            <option value="0">待审核</option>
                            <option value="1">审核通过</option>
                            <option value="2">审核不通过</option>
                        </select>
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">有效状态</div>
                    <div class="field">
                        <select name="flowStatus" id="flowStatus">
                            <option value=" " selected="selected">请选择</option>
                            <option value="1">有效</option>
                            <option value="2">无效</option>
                        </select>
                    </div>
                </div>
                <div class="clearFix"></div>
                <div class="btnsBox formBtns notRight">
                    <span id="searchBtn" class="sq-button-round">查询</span>
                    <span id="clearBtn" class="sq-button-round">清空</span>
                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
                    <%--<span id="addBtn" class="sq-button sq-button-round"> 新增</span>--%>
                </div>
            </div>
        </form>
    </div>
    <!-- 列表显示块 -->
    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null;
    $(function () {
        initForm();//初始化表单
        // initGrpCdList();//初始化下拉框
        initGrid();//注意初始化要在initForm之后,因为在初始化grid的时候需要form参数
        searchBtnEvent();//查询按钮事件
        clearBtnEvent();//清空按钮事件
    });

    //初始化表单
    function initForm(){
        $("#searchBar").ligerForm();
    }

    //初始化下拉框
    function initGrpCdList(){
        var _url = "<%=path%>/comm/dictionary/initList.do";
        var form = new liger.get("searchBar");
        var data = form.getData();
        data.page = 1;
        data.pagesize = 1000;
        AjaxUtils.ajaxGet(_url, data, initCallback, true);
    }

    //初始化下拉框回调
    function initCallback(msg){
        $.each(msg.rows,function(index,obj) {
            var option = "<option value='"+obj.codeGrpCd+"'>"+ (obj.codeGrpCd +"-"+ obj.codeGrpNm) +"</option>";
            $(option).appendTo("#cacheCodeGrpCdId");
        });
        liger.get("cacheCodeGrpCdId").setSelect();
        $("#cacheCodeGrpCdId").add_ligerFormEditor();
    }

    //查询参数
    function getSearchParams(){
        var form = new liger.get("searchBar");
        var data = form.getData();
        return data;
    }

    //初始化列表
    function initGrid(){
        $("#ligergrid1").ligerGrid({
            url:'<%=path%>/liveappeal/liveappeal/initList.do',
            method:'get',
            parms:getSearchParams(),
            columns:[
                { display: '客户名称', name: 'usrNm', width: 80, align:'center', enabledSort:true},
                { display: '证件类型', name: 'certType', width: 80, align:'center', enabledSort:true},
                { display: '证件号', name: 'certNo', width: 160, align:'center', enabledSort:true},
                { display: '名单类型', name: 'listType', width: 80, align:'center', enabledSort:true},
                { display: '活体类型', name: 'liveType', width: 80, align:'center', enabledSort:true},
                { display: '开始时间', name: 'crtTm', width: 120, align:'center', render:renderDate, enabledSort:true},
                { display: '结束时间', name: 'finishTm', width: 120, align:'center', render:renderDate, enabledSort:true},
                { display: '创建时间', name: 'crtTm', width: 120, align:'center', render:renderDate, enabledSort:true},
                { display: '有效状态', name: 'isValid', width: 60 , enabledSort:true,
                    render:function(rowData){
                        if (rowData.finishTm.after(new Date())) {
                            return "失效";
                        } else {
                            if (rowData.status=="1") {
                                return "有效";
                            } else {
                                return "无效";
                            }
                        }
                    }
                },
                { display: '审批状态', name: 'status', width: 60 , enabledSort:true,
                    render:function(rowData){
                        if (rowData.status=="1") {
                            return "审核通过";
                        }else if (rowData.status=="2") {
                            return "审核不通过";
                        } else if (rowData.status=="0") {
                            return "待审核";
                        }
                    }
                },
                { display: '来源', name: 'source', width: 80, align:'center', enabledSort:true}
            ],
            pageSize:10,
            root:'rows',
            record:'total',
            hideLoadButton:false,
            width:'100%',
            height:'100%',
            heightDiff:-2,
            checkbox:true,//列表是否有选择框
            rownumbers:true//列表是否有行号
        });
        grid = liger.get("ligergrid1");
        grid.setHeight(100);
        grid.options.isSingleCheck = true;//列表是否为单选
    }

    //查询按钮事件
    function searchBtnEvent(){
        $("#searchBtn").click(function(event) {
            var form = new liger.get("searchBar");
            var data = form.getData();
            for (name in data){
                grid.setParm(name,data[name]);
            };
            grid.reload();
        });
    }

    //清空按钮事件
    function clearBtnEvent(){
        $("#clearBtn").click(function(event) {
            $("#resetBtn").click();  //重置 input-text
            var form = liger.get("searchBar");
            form.setData({  //重置select等特殊表单
                "certNo":"",
                "usrNm":"",
                "flowStatus":"",
                "status":""
            });
        });
    }

    function renderDate(rowdata, index, value){
        var dateStr = "";
        if(null != value&&value!=''){
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }
</script>
</body>
</html>